﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using QuanLiNhaSachBUS;
using QuanLiNhaSachDTO;

namespace QuanLiNhaSachGUI
{
    public partial class frmQuiDinh : Form
    {
        public frmQuiDinh()
        {
            InitializeComponent();
        }

        private void frmQuiDinh_Load(object sender, EventArgs e)
        {
            tbDiaChi.Text = QuiDinhBUS.LayGiaTri("DiaChi");
            tbEmail.Text = QuiDinhBUS.LayGiaTri("Email");
            tbSoDienThoai.Text = QuiDinhBUS.LayGiaTri("DienThoai");
            tbTenCuaHang.Text = QuiDinhBUS.LayGiaTri("TenNhaSach");
            tbWebsite.Text = QuiDinhBUS.LayGiaTri("Website");

            lbTenCuaHang.Visible = false;
            lbDiaChi.Visible = false;
            lbSoDienThoai.Visible = false;
            lbEmail.Visible = false;
            lbWebsite.Visible = false;
        }

        private void btnLuu_Click(object sender, EventArgs e)
        {
            QuiDinhBUS.Luu("DiaChi", tbDiaChi.Text);
            QuiDinhBUS.Luu("Email", tbEmail.Text);
            QuiDinhBUS.Luu("DienThoai", tbSoDienThoai.Text);
            QuiDinhBUS.Luu("TenNhaSach", tbTenCuaHang.Text);
            QuiDinhBUS.Luu("Website", tbWebsite.Text);
            lbTenCuaHang.Visible = false;
            lbDiaChi.Visible = false;
            lbSoDienThoai.Visible = false;
            lbEmail.Visible = false;
            lbWebsite.Visible = false;
        }

        private void btnThoat_Click(object sender, EventArgs e)
        {
            if (lbTenCuaHang.Visible == true || lbDiaChi.Visible == true || lbSoDienThoai.Visible == true ||
                lbEmail.Visible == true || lbWebsite.Visible == true)
            {
                DialogResult r = MessageBox.Show("Một vài thông tin chưa được lưu, Bạn có chắc chắn muốn thoát ?", "Thoát", MessageBoxButtons.YesNo);
                if (r == System.Windows.Forms.DialogResult.Yes)
                    this.Close();
            }
            else 
                this.Close();
        }

        private void tbTenCuaHang_TextChanged(object sender, EventArgs e)
        {
            lbTenCuaHang.Visible = true;
        }

        private void tbDiaChi_TextChanged(object sender, EventArgs e)
        {
            lbDiaChi.Visible = true;
        }

        private void tbSoDienThoai_TextChanged(object sender, EventArgs e)
        {
            lbSoDienThoai.Visible = true;
        }

        private void tbEmail_TextChanged(object sender, EventArgs e)
        {
            lbEmail.Visible = true;
        }

        private void tbWebsite_TextChanged(object sender, EventArgs e)
        {
            lbWebsite.Visible = true;
        }
    }
}
